#include "DetailNotice.h"
#include "ui_DetailNotice.h"

DetailNotice::DetailNotice(QString topic, QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::DetailNotice)
{
    ui->setupUi(this);
    db = DBOperation::getInstance();
    db->open();
    qDebug() << topic;
    ui->topicLineEdit->setReadOnly(true);
    ui->authorLineEdit->setReadOnly(true);
    ui->contentTextEdit->setReadOnly(true);
    ui->datetimeLineEdit->setReadOnly(true);

    QString sql = "select * from notice";

    db->operate(sql);
    qDebug() << sql;
//    while (db->getNext()) {
//        if (db->getValue("topic") == topic) {
//            qDebug() << topic << db->getValue("content").toString();
//            ui->topicLineEdit->setText(db->getValue("topic").toString());
//            ui->contentTextEdit->setText(db->getValue("content").toString());
//            ui->authorLineEdit->setText(db->getValue("author").toString());
//            ui->datetimeLineEdit->setText(db->getValue("createDate").toDateTime().toString("yyyy-MM-dd hh:mm:ss"));
//            break;
//        }
//    }
}

DetailNotice::~DetailNotice()
{
    delete ui;
}

void DetailNotice::on_returnPushButton_clicked()
{
    this->close();
}
